package com.xzavier.yunlian_interview.config;

import com.xzavier.yunlian_interview.utils.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        HandlerInterceptor interceptor = new LoginInterceptor();
        List<String> list = new ArrayList<String>();
        list.add("/interview/question/**");
        list.add("/interview/User/reg");
        list.add("/interview/User/login");
        list.add("/interview/project/getAll");
//        list.add("/interview/time/**");
        registry.addInterceptor(interceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(list);
    }
}
